1. Technical Field
The present invention relates to three-dimensional computer graphics technology and in particular to hidden surface removal technology for an object in three-dimensional space.
2. Background Art
In order to display an object in three-dimensional space expressed by a computer on a display means, it is necessary to project the object onto a two-dimensional plane (hereafter, “viewscreen”) that shows the object. At this time, in the case where plural objects overlap in the visual axis, it is necessary to remove the part of the further object that is hidden by the nearer object before displaying the objects in the display. Such a hidden surface removal method is indispensable in the rendering of three-dimensional computer graphics (hereafter, also called “3DCG”).
The Z-buffer method (for example, see Non-Patent Reference 1) can be given as a generally frequently-used hidden surface removal method. FIG. 1A is a diagram for describing the Z-buffer method.
With the Z-buffer method, a buffer (hereafter, “Z-buffer”) is provided for storing Z-coordinate values (hereafter, “Z value”) of a point where a straight line, which connects a viewpoint V that corresponds to each pixel of a viewscreen 900 with the pixels on the viewscreen 900, intersects with a surface (for example, a polygon indicating an object in three-dimensional space). The Z value increases the further away the viewpoint becomes. In addition, a buffer for storing a pixel value (for example, a color value, a luminance value, and the like) of each pixel (hereafter, “frame buffer”) is provided.
FIG. 1A shows a state where two polygons, a polygon 910 and a polygon 920, intersect with one another in three-dimensional space, and these polygons are projected on the viewscreen 900. In this case, the part projected in a pixel 930 of the viewscreen 900 is the part of a point A of the polygon 910, and a point B of the polygon 920 is hidden by the point A of the polygon 910. This is because when the straight line stretching from the viewpoint V to the pixel 930 is extended, a distance ZA between the viewpoint V and the point A is shorter than a distance ZB between the viewpoint V and the point B, and thus, from the viewpoint V, only the point A of the polygon 910, which is closer, is projected on the viewscreen 900.
FIG. 1B is a display example of an image where hidden surface removal using the Z-buffer method has been carried out (in other words, the polygon 910 and the polygon 920 are projected on the viewscreen 900). In FIG. 1B, parts in each polygon with a lower Z value are indicated by a darker black color.
A procedure in the case of carrying out hidden surface removal using the Z-buffer method is as follows.                (1) The Z values in the Z-buffer are initialized to “+∞”, and the pixel values in the frame buffer are initialized to “background color”, for all pixels in the viewscreen.        (2) All polygons in the three-dimensional space (also called “view volume”) that are to be projected are sequentially projected in the viewscreen, and the following processing is performed on all pixels corresponding to each polygon.        (2-1) The Z value is calculated per pixel that corresponds to the polygon to be processed.        (2-2) Only when the Z value calculated in the above (2-1) is lower than the Z value of the corresponding pixel which is stored in the Z-buffer, the pixel value of that pixel is calculated, and the Z value in the Z-buffer and the pixel value in the frame buffer are updated.        
Next, the procedure in the case of carrying out hidden surface removal using the Z-buffer method shall be described in further detail, with reference to FIGS. 2A through 2D.
FIG. 2A is an example of an image made up of 8×8 pixels, in which rendering of a polygon 901 has already finished (note that in FIG. 2A, a memory address is indicated by [N-M]). FIG. 2B shows an image in which a new polygon 902 is additionally rendered in FIG. 2A. The Z value corresponding to each pixel is shown in each cell of FIGS. 2A and B. FIG. 2C is an example of pixel values stored in the frame buffer and Z values stored in the Z-buffer, which corresponds to the above FIG. 2A.
As shown in FIG. 2B, when additionally rendering the polygon 902 in the image in which the polygon 901 has been rendered, of the pixels corresponding to the polygon 902, only the pixels with a Z value smaller than the pixels that already correspond to the polygon 901 are employed and rendered in the viewscreen.
The pixel values stored in the frame buffer and the Z values stored in the Z-buffer after the above processing has finished are shown in FIG. 2D. As shown in FIG. 2D, the respective pixel values and Z values are updated only in the case where the Z values of the pixels corresponding to the polygon 902 are smaller than the Z values of the pixels corresponding to the polygon 901.
Through the above procedure, image data, of an image on which hidden surface removal has been carried out and which is an image to be displayed in an actual display that corresponds to the viewscreen, is ultimately stored in the frame buffer.
As described above, the Z-buffer method does require a high-capacity buffer (memory) for storing the pixel values and Z values for all pixels in the viewscreen, but because the algorithm is simple, the method can easily be implemented as hardware, and is used in many devices which carry out rendering in real time.
Non-Patent Reference 1: Araya, Shinji. Meikai Sanjigen Conpyuta Gurafikkusu (Three-Dimensional Computer Graphics Explained). 2003: Kyoritsu Publishing.
However, with a conventional image generation device that uses the aforementioned Z-buffer method, reading/writing in the frame buffer and Z-buffer must be carried out continually, for each pixel corresponding to each polygon, and thus an enormous number of memory accesses occur. Therefore, high-speed access is required when accessing the frame buffer and the Z-buffer.
Moreover, in three-dimensional computer graphics, in order to bring rendering processing efficiency to the maximum limit, it is preferable to have the data length of the smallest processing unit for reading/writing (hereafter, “burst length”) be the same as the data (including the pixel value and Z value) length of one pixel; it is also necessary to use a memory in which the waiting time during reading/writing (hereafter, “latency”) is low.
However, in a system LSI, in which one chip includes a variety of functions, and no particular emphasis is placed on three-dimensional computer graphics processing, there are many cases where a memory suitable for three-dimensional computer graphics processing is not necessarily included (for example, the case where the burst length at the time of a read/write is significantly longer than one pixel's worth of data). In such a system LSI, in the case where the burst length at the time of a read/write is significantly longer than one pixel's worth of data, pixel data of pixels that have no relation to the polygon being rendered is accessed as well, and the processing efficiency drops at the time of a memory access.
Furthermore, in the case of high latency at the time of a memory access, most of the time spent waiting cannot be used for rendering processing, and must be spent waiting idly. Therefore, there is a problem in that the processing efficiency during rendering processing drops, an image that moves smoothly cannot be obtained, and so on, which leads to a decrease in image quality.
Accordingly, an object of the present invention is to solve the aforementioned problem by providing an image generation device which can avoid a drop in processing efficiency during rendering processing even in the case of employing the Z-buffer method in hidden surface removal.